package com.medi.business.domain;

import com.fasterxml.jackson.annotation.JsonInclude;

import java.io.Serializable;
import java.util.List;
import java.util.stream.Collectors;

/**
 * CateGoryTreeSelect
 *
 * @author medi
 */
public class TreeSelectModel implements Serializable {
    private static final long serialVersionUID = 1L;

    /**
     * 节点ID
     */
    private String id;

    /**
     * 节点名称
     */
    private String label;

    /**
     * 节点图片
     */
    private String avatar;

    /**
     * 祖籍列表
     */
    private String ancestors;


    /**
     * 父节点id
     */
    private String pid;

    /**
     * 是否被选择
     */
    private boolean isChoose;
    /**
     * 子节点
     */
    @JsonInclude(JsonInclude.Include.NON_EMPTY)
    private List<TreeSelectModel> children;

    public TreeSelectModel() {

    }

    public TreeSelectModel(CompanyInfo companyInfo) {
        this.id = companyInfo.getId();
        this.label = companyInfo.getCustName();
        this.ancestors = companyInfo.getAncestors();
        this.pid = companyInfo.getParentId();
        this.isChoose = false;
        this.children = companyInfo.getChildren().stream().map(TreeSelectModel::new).collect(Collectors.toList());
    }

    public TreeSelectModel(OrgInfo orgInfo) {
        this.id = orgInfo.getOrgId();
        this.label = orgInfo.getOrgName();
        this.pid = orgInfo.getParentId();
        this.isChoose = false;
        this.children = orgInfo.getChildren().stream().map(TreeSelectModel::new).collect(Collectors.toList());
    }




    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getLabel() {
        return label;
    }

    public void setLabel(String label) {
        this.label = label;
    }

    public List<TreeSelectModel> getChildren() {
        return children;
    }

    public void setChildren(List<TreeSelectModel> children) {
        this.children = children;
    }

    public String getAvatar() {
        return avatar;
    }

    public void setAvatar(String avatar) {
        this.avatar = avatar;
    }


    public String getPid() {
        return pid;
    }

    public void setPid(String pid) {
        this.pid = pid;
    }

    public boolean isChoose() {
        return isChoose;
    }

    public void setChoose(boolean choose) {
        isChoose = choose;
    }
}
